export function fetchProduct (params) {
  return new Promise ((resolve) => {
    setTimeout(() => {
      resolve(getTestData(params))
    }, 1000);
  })
}

const getTestData = function (params) {
  testData[2] = {
    productId: 10000 + params,
    productName: '小米-' + params,
    skuChildren: [
      {
        skuId: '小米-' + params,
        skuName: 'iPhone 13 Pro Max 256G 黑色' + '小米-' + params,
        color: '黑色',
        size: '256G'
      }
    ]
  }
  testData[3] = {
    productId: 10001 + params,
    productName: '测试-' + params,
    skuChildren: [
      {
        skuId: '测试-' + params,
        skuName: 'iPhone 13 Pro Max 256G 黑色' + '测试-' + params,
        color: '黑色',
        size: '256G'
      }
    ]
  }
  testData[4] = {
    productId: 10002 + params,
    productName: '三星-' + params,
    skuChildren: [
      {
        skuId: '三星-' + params,
        skuName: 'iPhone 13 Pro Max 256G 黑色' + '三星-' + params,
        color: '黑色',
        size: '256G'
      }
    ]
  }
  testData[5] = {
    productId: 10003 + params,
    productName: '华为-' + params,
    skuChildren: [
      {
        skuId: '华为-' + params,
        skuName: 'iPhone 13 Pro Max 256G 黑色' + '华为-' + params,
        color: '黑色',
        size: '256G'
      }
    ]
  }
  testData[6] = {
    productId: 10004 + params,
    productName: '一加-' + params,
    skuChildren: [
      {
        skuId: '一加-' + params,
        skuName: 'iPhone 13 Pro Max 256G 黑色' + '一加-' + params,
        color: '黑色',
        size: '256G'
      }
    ]
  }
  testData[7] = {
    productId: 10005 + params,
    productName: 'vivo-' + params,
    skuChildren: [
      {
        skuId: 'vivo-' + params,
        skuName: 'iPhone 13 Pro Max 256G 黑色' + 'vivo-' + params,
        color: '黑色',
        size: '256G'
      }
    ]
  }
  testData[8] = {
    productId: 10006 + params,
    productName: 'oppo-' + params,
    skuChildren: [
      {
        skuId: 'oppo-' + params,
        skuName: 'iPhone 13 Pro Max 256G 黑色' + 'oppo-' + params,
        color: '黑色',
        size: '256G'
      }
    ]
  }
  console.log(testData)
  return testData
}

// 假数据
var testData = [
  {
    productId: 9999,
    productName: 'iPhone 13 Pro Max',
    skuTag: [
      { title: "颜色", label: 'color', list: ['黑色', '白色', '红色'] },
      { title: '容量', label: 'size', list: ['128G', '256G'] }
    ],
    skuChildren: [
      {
        skuId: '999901',
        skuName: 'iPhone 13 Pro Max 256G 黑色',
        color: '黑色',
        size: '256G'
      },
      {
        skuId: '999902',
        skuName: 'iPhone 13 Pro Max 128G 黑色',
        color: '白色',
        size: '128G'
      },
      {
        skuId: '999903',
        skuName: 'iPhone 13 Pro Max 128G 红色',
        color: '红色',
        size: '128G'
      },
      {
        skuId: '999903',
        skuName: 'iPhone 13 Pro Max 256G 红色',
        color: '红色',
        size: '256G'
      }
    ]
  },
  {
    productId: 8888,
    productName: 'iPhone 12',
    skuTag: [
      { title: "颜色", label: 'color', list: ['黑色', '白色', '红色'] },
      { title: '容量', label: 'size', list: ['128G', '256G'] }
    ],
    skuChildren: [
      {
        skuId: '888801',
        skuName: 'iPhone 12 256G 黑色',
        color: '黑色',
        size: '256G'
      },
      {
        skuId: '888802',
        skuName: 'iPhone 12 128G 黑色',
        color: '白色',
        size: '128G'
      },
      {
        skuId: '888803',
        skuName: 'iPhone 12 128G 红色',
        color: '红色',
        size: '128G'
      },
      {
        skuId: '888803',
        skuName: 'iPhone 12 256G 红色',
        color: '红色',
        size: '256G'
      }
    ]
  }
]